<template>
  <section class="timeline-container timeline">
    <div
      @click="changeCurrentTimePoint(point)"
      v-for="(point,index) in points"
      class="timeline-block"
      :key="index"
    >
      <div
        :class="['timeline-img',point.status  != 1 ? 'red': 'green', point.node ? 'timeline-img-node' : '']"
      ></div>

      <div class="timeline-content">
        <h2>
          {{point.content}}
          <span>{{point.updatetime}}</span>
        </h2>
        <p v-text="point.content"></p>
      </div>
    </div>
  </section>
</template>
<style scoped lang="less">
@import "../utils/theme.less";

.timeline-container {
  width: 90%;
  max-width: 1024px;
  margin: 0 auto;
}
.timeline-container::after {
  /* clearfix */
  content: "";
  display: table;
  clear: both;
}
/* --------------------------------
  Main components
  -------------------------------- */
.timeline {
  position: relative;
  padding: 1vh 0;
  margin-top: 1vh;
  margin-bottom: 1vh;
  margin-top: 1vh;
  margin-bottom: 1vh;
  &::before {
    content: "";
    position: absolute;
    top: 0;
    left: 18px;
    height: 100%;
    width: 4px;
    background: #fff;
    left: 50%;
    margin-left: -2px;
  }
}

.timeline-block {
  position: relative;
  margin: 1.5vh 0;
  text-align: right;
}
.timeline-block:after {
  content: "";
  display: table;
  clear: both;
}
.timeline-block:first-child {
  margin-top: 0;
}
.timeline-block:last-child {
  margin-bottom: 0;
}

.timeline-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 6vh;
  height: 6vh;
  border-radius: 50%;
  box-shadow: 0 0 0 4px white, inset 0 2px 0 rgba(0, 0, 0, 0.08),
    0 3px 0 4px rgba(0, 0, 0, 0.05);
  left: 50%;
  margin-left: -3vh;
}

.timeline-img-node {
  width: 3vh;
  height: 3vh;
  top: 1.5vh;
  margin-left: -1.5vh;
}
.timeline-img.green {
  background: #2b821d;
}
.timeline-img.blue {
  background: #00b7e5;
}
.timeline-img.yellow {
  background: #ffff66;
}

.timeline-content {
  position: relative;
  background: white;
  border-radius: 0.25vw;
  padding: 0.5vw;
  // box-shadow: 0 0.3vw 0 #d7e4ed;
  margin-left: 0;
  width: 43%;
  min-height: 6vh;
  h2 {
    color: @primary;
    font-size: 1.3rem;
    margin-bottom: vh;
  }
  p {
    font-size: 1.3rem;
    margin: 0.5vw 0;
    line-height: 1.4;
  }
  &:after {
    content: "";
    display: table;
    clear: both;
  }
}

.timeline-content::before {
  content: "";
  position: absolute;
  top: 1.5vw;
  right: 100%;
  height: 0;
  width: 0;
  border: 7px solid transparent;
  border-right: 7px solid white;
}
.timeline-content::before {
  left: 100%;
  border-color: transparent;
  border-left-color: white;
}
.timeline-content .read-more {
  float: left;
}
.timeline-content .date {
  position: absolute;
  width: 100%;
  left: 122%;
  top: 6px;
  font-size: 16px;
  font-size: 1rem;
}
.timeline-block:nth-child(even) .timeline-content {
  float: right;
  text-align: left;
}
.timeline-block:nth-child(even) .timeline-content::before {
  left: auto;
  right: 100%;
  border-color: transparent;
  border-right-color: white;
}
.timeline-block:nth-child(even) .timeline-content .read-more {
  float: right;
}
.timeline-block:nth-child(even) .timeline-content .date {
  left: auto;
  right: 122%;
  text-align: right;
}

.no-info{
  text-align: center;
}
</style>
<script>
export default {
  props: {
    points: {
      required: true
    }
  },
  data() {
    return {
      defaultImg:
        ""
    };
  },
  components: {},
  methods: {
    getImg: function(imgurl) {
      var ImgObj = new Image(); // 判断图片是否存在
      ImgObj.src = imgurl;
      // 没有图片，则返回-1
      if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
        return imgurl;
      } else {
        return this.defaultImg;
      }
    },
    changeCurrentTimePoint: function(point) {
      this.$on("currentPoint", point);
    }
  }
};
</script>